package com.jxtti.service;

import org.apache.log4j.Logger;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.jxtti.dao.SubjectAuthDao;
import com.jxtti.entity.SubjectAuth;
/**
 * 
 * <br>
 * <b>功能：</b>SubjectAuthService<br>
 * <b>作者：lwb</b><br>
 * <b>日期：</b> Nov 26, 2015 <br>
 * <b>版权所有：<b>版权所有(C) 2015，<br>
 */
@Service("subjectAuthService")
@Transactional(rollbackFor = { RuntimeException.class, Exception.class })
public class SubjectAuthService {

	private final static Logger log= Logger.getLogger(SubjectAuthService.class);
	

	

	@Autowired
    private SubjectAuthDao subjectAuthDao;

		


	/**
	 * 获取信息数据列表
	 * 
	 * @param data
	 * @return
	 */
	public Map<String, Object> list(Map<String, Object> data,  SubjectAuth subjectAuth)
	{
		//int rowCount = subjectAuthDao.queryByCount(subjectAuth);//。queryByCount(tMonitorProjectInfo);
		//subjectAuth.getPager().setRowCount(rowCount);
		//List<SubjectAuth> lstSubjectAuth  = subjectAuthDao.queryByList(data);
	
	
	
	
		int pageNum = Integer.parseInt((data.get("currentPage") == null || data
				.get("currentPage").equals("0")) ? "1" : data.get("currentPage").toString());
		// 每页显示条数 
		int pageSize = Integer.parseInt((data.get("pageSize") == null || data.get("pageSize").equals("0")) ? "10" : data.get("pageSize").toString());
		PageHelper.startPage(pageNum, pageSize);
		PageInfo<SubjectAuth> pages = new PageInfo<SubjectAuth>( subjectAuthDao.queryByList(data));
		data.put("page", pages);
		return data;
	}
	
	
	
	/**
	 * 查询所有数据。 
	 * @param data
	 * @return
	 */
	public List<SubjectAuth>  queryAll(Map<String, Object> data)
	{
		return  subjectAuthDao.queryByList(data);
	}
	
	
	
	/**
	 * 添加数据.
	 * 
	 * @param data
	 * @return
	 */
	public int add(SubjectAuth subjectAuth)
	{
		int insertCount = subjectAuthDao.add(subjectAuth);
		return insertCount;
	}
	

	/**
	 * 修改数据.
	 * 
	 * @param data
	 * @return
	 */
	public int update(SubjectAuth subjectAuth)
	{
		int updateCount = subjectAuthDao.update(subjectAuth);
		return updateCount;
	}
	


	/**
	 * 修改不为空的数据.
	 * 
	 * @param data
	 * @return
	 */
	public int updateBySelective(SubjectAuth subjectAuth)
	{
		int updateCount = subjectAuthDao.updateBySelective(subjectAuth);
		return updateCount;
	}


	/**
	 * 删除数据.
	 * 
	 * @param data
	 * @return
	 */
	public int delete(SubjectAuth subjectAuth)
	{
		int deleteCount = subjectAuthDao
				.delete(subjectAuth);
		
		return deleteCount;
	}
	
	
	public int deleteAuth(SubjectAuth subjectAuth)
	{
		int deleteCount = subjectAuthDao
				.deleteAuth(subjectAuth);
		
		return deleteCount;
	}
	
	public SubjectAuth querySubjectAuthById(SubjectAuth subjectAuth)
	{
		subjectAuth = subjectAuthDao.querySubjectAuthById(subjectAuth);
		return subjectAuth;
	}

}
